execute align xz positioned ~0.5 ~ ~0.5 if entity @e[tag=mystic_pedestal,distance=..0.5,type=item_display] run function dab:system/mystic_pedestal/break_nearest

#CREATE

#Main
execute align xz positioned ~0.5 ~ ~0.5 run summon item_display ~ ~ ~ {Tags:["summon","mystic_pedestal",mystic_pedestal.entity,"has_effect"],item:{id:"poisonous_potato",components:{item_model:"dab:mystic_pedestal"}}}
data merge entity @n[tag=summon,type=item_display,distance=..3] {transformation:{scale:[1.6f,1.6f,1.6f],translation:[0.0f,0.75f,0.0f]}}

#display
summon item_display ~ ~ ~ {Tags:["summon1","mystic_pedestal.display",mystic_pedestal.entity],item:{id:"poisonous_potato"},teleport_duration:3}
data merge entity @n[tag=summon1,type=item_display,distance=..1] {transformation:{translation:[0.0f,1.75f,0.0f],scale:[0.75f,0.75f,0.75f]}}
ride @n[tag=summon1,distance=..1,type=item_display] mount @n[tag=summon,type=item_display,distance=..3]

#text
summon text_display ~ ~ ~ {Tags:["mystic_pedestal.entity","summon2","mystic_pedestal.text"],billboard:"vertical"}
data modify entity @n[tag=summon2,type=text_display,distance=..1] transformation.translation[1] set value 2.25f
ride @n[tag=summon2,distance=..1,type=text_display] mount @n[tag=summon,type=item_display,distance=..3]

#interaction
summon interaction ~ ~ ~ {Tags:["mystic_pedestal.entity",summon3,"mystic_pedestal.interaction"],height:2.0f,response:true}
ride @n[tag=summon3,distance=..1,type=interaction] mount @n[tag=summon,type=item_display,distance=..3]

#set effect
execute as @n[tag=summon,distance=..3,type=item_display] at @s run function dab:system/mystic_pedestal/random_effect/random_effect

tag @n[tag=summon,distance=..3,type=item_display] remove summon
tag @n[tag=summon1,distance=..1,type=item_display] remove summon1
tag @n[tag=summon2,distance=..1,type=text_display] remove summon2
tag @n[tag=summon3,distance=..1,type=interaction] remove summon3